package com.icesoft.xsnow.upms.api.param;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.icesoft.xsnow.framework.api.param.ICreate;
import com.icesoft.xsnow.framework.api.param.IUpdate;
import com.icesoft.xsnow.upms.api.po.SysUser;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @program: xsnow
 * @description: 用户
 * @author: xuefeng.gao
 * @create: 2019-05-20 10:49
 **/
@ApiModel
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class UserParam  extends SysUser {

    @TableId(type = IdType.AUTO)
    @NotBlank(groups = {IUpdate.class}, message = "用户id不允许为空")
    protected Integer id;

    /**
     * 用户名
     **/
    @Size(min = 4,max = 20,message = "用户名长度在4-20之间")
    @NotBlank(groups = {ICreate.class,IUpdate.class}, message = "用户名不允许为空")
    private String username;

    /**
     * 密码,加密存储
     **/
    @Size(min = 5,max = 20,message = "密码长度在5-20之间")
    @NotBlank(groups = {ICreate.class},message = "密码不允许为空")
    private String password;

    /**
     * 注册手机号
     **/
    @Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$",message = "手机号码格式错误")
    @NotBlank(groups = {ICreate.class},message = "手机号不允许为空")
    private String phone;
    /**
     * 注册邮箱
     **/
    @Email(message = "Email格式错误" )
    @NotBlank(groups = {ICreate.class},message = "email不允许为空")
    private String email;
}
